package com.xiaoma.h5testdemo.business.main.ui

import android.os.Bundle
import android.text.TextUtils
import com.xiaoma.common.extend.getColorRes
import com.xiaoma.common.extend.getDrawableRes
import com.xiaoma.h5testdemo.R
import com.xiaoma.h5testdemo.common.ui.XmJsDialog
import com.xiaoma.h5testdemo.databinding.DialogPromptBinding

/**
 * author: liangjingbo
 * date: 2023/11/22
 * describe:
 */
class XmPromptDialog : XmJsDialog<DialogPromptBinding>(DialogPromptBinding::inflate) {
    override fun initView(savedInstanceState: Bundle?) {
        if (!TextUtils.isEmpty(mBuilder.mContentText)) {
            binding.tvContent.text = mBuilder.mContentText
        }
    }

    override fun initEvent(savedInstanceState: Bundle?) {
        binding.tvSure.setOnClickListener {
            hideDialog()
            mBuilder.mPositiveButtonListener?.invoke()
        }
    }

    override fun onUiModeChange() {
        super.onUiModeChange()
        binding.apply {
            val context = root.context
            root.background = context.getDrawableRes(R.drawable.drawable_dialog_privacy_policy_bg)
            tvTitle.setTextColor(context.getColorRes(R.color.color_dialog_tv_title))
            scrView.verticalScrollbarThumbDrawable = context.getDrawableRes(R.drawable.drawable_scrollbar_thumb)
            tvContent.setTextColor(context.getColorRes(R.color.color_tv_content))
            tvSure.background = context.getDrawableRes(R.drawable.drawable_tv_sure_bg)
            tvSure.setTextColor(context.getColorRes(R.color.color_tv_sure))
        }
    }
}